package com.geostar.gmp.utils;
/**
 * 
 * 创建数据库ID的通用方法.
 * @since JDK1.6
 */

public class CreateID {

	/**
	 * 随机创建数据库9位ID
	 * 
	 * @return String 9位随机数ID
	 */
	public synchronized static String generate9() {

		int n = (int) (Math.random() * 900000000) + 100000000;
		return n + "";
	}

	/**
	 * 创建15位字母加数字ID
	* bl 为true是为暂停时间
	 * 
	 * @return string 15位随机ID
	 */
	public synchronized static String generateStrID(String str) {
		int count = 0;
		String time = Long.toString(System.currentTimeMillis());
		time = time.substring(time.length() - 9, time.length());
		if (count > 99) {
			count = 0;
		} else {
			count++;
		}
		if (count < 10) {
			str += time + "0" + count;
		} else {
			str += time + count;
		}
		return str;
	}
}